/* Copyright 2009 Requirements Management System 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.mags.remas.model.entity.provider;

// Generated Dec 6, 2009 5:47:57 PM by Hibernate Tools 3.2.2.GA
// powered by MAGS

import java.io.Serializable; 
import org.mags.dao.provider.CacheableDataProvider;
import org.mags.remas.model.entity.EntityStatus;

public class EntityStatusProvider extends CacheableDataProvider<EntityStatus> {
	private static final long serialVersionUID = 1L;
	public EntityStatusProvider() {
	}
	public EntityStatus getActiveStatus() {
		return this.getByCode("ACTIVE");
	}
	public boolean isActiveStatus(EntityStatus entityStatus) {
		return (entityStatus.getEntityStatusId()==this.getActiveStatus().getEntityStatusId())||
		(entityStatus.getEntityStatusParent()!=null&&isActiveStatus(entityStatus.getEntityStatusParent()));
	}
	public EntityStatus getInactiveStatus() {
		return this.getByCode("INACTIVE");
	}
	public boolean isInactiveStatus(EntityStatus entityStatus) {
		return (entityStatus.getEntityStatusId()==this.getInactiveStatus().getEntityStatusId())||
		(entityStatus.getEntityStatusParent()!=null&&isInactiveStatus(entityStatus.getEntityStatusParent()));
	}
	public EntityStatus getByCode(String code) {
		for(EntityStatus i: this.getAll())
			if(code.equalsIgnoreCase(i.getCode()))
				return i;
		return null;
	}
	public EntityStatus getById(Serializable id) {
		for(EntityStatus i: this.getAll())
			if(i.getEntityStatusId()==((Short)id).intValue())
				return i;
		return null;
	}
	protected void loadProperties(EntityStatus one) {
	}
}
